package com.zhilifang.modules.zlf.controller;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhilifang.modules.zlf.entity.Fslink;
import com.zhilifang.modules.zlf.service.impl.FslinkServiceImpl;
import com.zhilifang.modules.zlf.utils.Pager;
import com.zhilifang.modules.zlf.utils.QueryString;
import com.zhilifang.modules.zlf.utils.Result;

/**
 * Controller 后台首页>>SEO优化Controller
 */
@Controller
@RequestMapping("/fslinkController")
public class FslinkController {

	@Autowired
	private FslinkServiceImpl fslinkServiceImpl ;
	
	
	
	/**
	 * 分页查询
	 * 
	 * @return
	 */
	@RequestMapping(value = "/selectPageQueryString", method = RequestMethod.POST)
	@ResponseBody
	public Pager<Fslink> selectPageQueryString(QueryString queryString){
		Pager<Fslink> pager = new Pager<Fslink>();
		Fslink fslink =  new Fslink();
		if(!"".equals(queryString.getReady01())&&queryString.getReady01()!=null){
			fslink.setName("%"+queryString.getReady01()+"%");  //查询内容
		}
		List<Fslink> list = fslinkServiceImpl.selectFslinkListr(fslink);
		if (list != null&&!list.isEmpty()) {
			pager=new Pager<Fslink>(queryString.getCurrentPage(),queryString.getPageSize(), list);
		}
		return pager;
	}
	
	
	
	/**
	 * 新增&&修改
	 * 
	 * @return
	 */
	@RequestMapping(value = "/insertUpdate", method = RequestMethod.POST)
	@ResponseBody
	public Result insertUpdate(Fslink record){
		Result result = new Result();
		if(record.getId()!=null&&!"".equals(record.getId())){
			fslinkServiceImpl.updateByPrimaryKeySelective(record);
		}else{
			fslinkServiceImpl.insert(record);
		}
		result.setMessage("新增&&修改成功");
		result.setState("200");
		return result;
	}
	
	/**
	 * 删除
	 * 
	 * @return
	 */
	@RequestMapping(value = "/deleteByPrimaryKey", method = RequestMethod.POST)
	@ResponseBody
	public Result deleteByPrimaryKey(int id){
		Result result = new Result();
		fslinkServiceImpl.deleteByPrimaryKey(id);
		result.setMessage("删除成功");
		result.setState("200");
		return result;
	}
	
	
	/**
	 * 查询详情
	 * 
	 * @return
	 */
	@RequestMapping(value = "/selectByPrimaryKey", method = RequestMethod.POST)
	@ResponseBody
	public Fslink selectByPrimaryKey(int id){
		return fslinkServiceImpl.selectByPrimaryKey(id);
	}
	
	

	
	
	
}
